<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%" ref="multipleTable"
      v-loading="tableLoading"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading">
      <el-table-column prop="tableName" label="表名">
        <template slot-scope="scope">
          <router-link :to="{name: 'genColumn', params: {tableName: scope.row.tableName, comment: scope.row.comment}}">{{scope.row.tableName}}</router-link>
        </template>
      </el-table-column>
      <el-table-column prop="comment" label="备注"/>
    </el-table>
  </div>
</template>

<script>
import * as gen from '@/api/gen'

export default {
  name: 'TableList',
  data () {
    return {
      tableData: [], // 表格数据
      tableLoading: true
    }
  },
  methods: {
    getTables () {
      gen.getTables().then(res => {
        this.tableData = res.data;
        this.tableLoading = false;
      });
    }
  },
  created () {
    this.getTables();
  }
}
</script>
